package bigDecimalTset;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class BigDecimalTest {
    public static void main(String[] args) {
        bigDecimalTest();

    }

    public static void bigDecimalTest() {
        //不能给double类型数字,最好使用String 类型
        BigDecimal bigDecimal = new BigDecimal("6.12");
        BigDecimal bigDecimal2 = new BigDecimal("8");
        System.out.println("和 :" + bigDecimal.add(bigDecimal2));
        BigDecimal bigInt1 = new BigDecimal("6");
        BigDecimal bigInt2 = new BigDecimal(8);
        System.out.println("差 :" + bigInt1.subtract(bigInt2));
        BigDecimal bigInt3 = new BigDecimal(6L);
        BigDecimal bigInt4 = new BigDecimal(8);
        System.out.println("积 :" + bigInt3.multiply(bigInt4));

        BigDecimal bigInt5 = new BigDecimal(6);
        BigDecimal bigInt6 = new BigDecimal(8);
        BigDecimal divResult = bigInt5.divide(bigInt6, 3, RoundingMode.HALF_UP);
        System.out.println("商 :" + divResult);
    }


}
